﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using caedisi.Web.DataModel;
using System.Collections.ObjectModel;
using System.ComponentModel;
using caedisi.Models;
using System.Windows.Controls;
using System.Windows;

namespace caedisi.Views
{
    /// <summary>
    /// 
    /// </summary>
    public partial class TransitionRulesValidationReport : ChildWindow, INotifyPropertyChanged
    {

        private Collection<RuleValidationError> _TransitionRulesCollisionErrors;
        /// <summary>
        /// Gets or sets the transition rules collision errors.
        /// </summary>
        /// <value>
        /// The transition rules collision errors.
        /// </value>
        public Collection<RuleValidationError> TransitionRulesCollisionErrors
        {
            get
            {
                return _TransitionRulesCollisionErrors;
            }
            set
            {
                if (_TransitionRulesCollisionErrors != value)
                {
                    _TransitionRulesCollisionErrors = value;
                    this.RaisePropertyChanged("TransitionRulesCollisionErrors");

                }
            }
        
        }

        public bool IsListBoxCollisionRulesVisible { get { return (this.TransitionRulesCollisionErrors==null || (this.TransitionRulesCollisionErrors!=null && this.TransitionRulesCollisionErrors.Count>0));} }


        private Collection<RuleValidationError> _InclusionRulesCollisionErrors;
        /// <summary>
        /// Gets or sets the inclusion rules collision errors.
        /// </summary>
        /// <value>
        /// The inclusion rules collision errors.
        /// </value>
        public Collection<RuleValidationError> InclusionRulesCollisionErrors
        {
            get
            {
                return _InclusionRulesCollisionErrors;
            }
            set
            {
                if (_InclusionRulesCollisionErrors != value)
                {
                    _InclusionRulesCollisionErrors = value;
                    this.RaisePropertyChanged("InclusionRulesCollisionErrors");

                }
            }
        }

        public bool IsListBoxInclusionRulesVisible { get { return (this.InclusionRulesCollisionErrors == null || (this.InclusionRulesCollisionErrors != null && this.InclusionRulesCollisionErrors.Count > 0)); } }

        /// <summary>
        /// Initializes a new instance of the <see cref="TransitionRulesValidationReport"/> class.
        /// </summary>
        public TransitionRulesValidationReport(Collection<RuleValidationError> transitionRulesCollisionErrors, Collection<RuleValidationError> inclusionRulesCollisionErrors)
        {
            InitializeComponent();

            this.TransitionRulesCollisionErrors = transitionRulesCollisionErrors;
            this.InclusionRulesCollisionErrors = inclusionRulesCollisionErrors;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="TransitionRulesValidationReport"/> class.
        /// </summary>
        public TransitionRulesValidationReport()
        {
            InitializeComponent();
        }

        private void CorrectTheRulesButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        /// <summary>
        /// Handles the Click event of the IgnoreButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void IgnoreButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        #region INotifiedPropertyChange
        public event PropertyChangedEventHandler PropertyChanged;
        /// <summary>
        /// Raises the property changed.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        protected virtual void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        } 
        #endregion
    }
}

